package com.company.serialization;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2021/1/1 18:27
 */
public class StudentStreamSizeTest  {


    public static void main(String[] args) throws IOException {
        Student s = new Student("GG",14);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(s);
        objectOutputStream.flush();
        objectOutputStream.close();
        byte[] b = byteArrayOutputStream.toByteArray();
        System.out.println("jdk的序列化长度："+b.length);  // jdk的序列化长度：97

        System.out.println("---------------------------");
        System.out.println("ByteBuffer序列化机制的序列化长度："+s.codeC().length);  // ByteBuffer序列化机制的序列化长度：10

    }




}
